Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nice_things/lang/quote.sh

quote

Since 0.3.0 · Source

import "{ quote }" from nice_things/lang/quote.sh

Synopsis
quote <out_var> [<string>…]

Configuration

Description
Quote <string> arguments to make them safe to eval; assign to <out_var> as a quoted list separated by a space character.

For streaming use-cases, when you want to read text from stdin and print quoted text to stdout, in a pipeline, check out the escape_single_quotes function.

Options

Operands

  • <out_var>: Output variable; the result will be written to this variable.
  • <string>: A value to be quoted.

Stdin

Stdout

Stderr

Exit status
0: Successful completion.

Abort

Usage examples

# Save quoted arguments in a variable
quote NS__arguments "$@"

# Restore arguments from quoted variable
eval " set -- ${NS__arguments}"